<?php
session_start();

if(!isset($_SESSION['userid']))//检查 userid 是否已经设置，如果没有设置，提示未登录并跳转首页
{
    echo "<script>alert('您尚未登录！')</script>";
    echo "<script>window.location.href='index.php'</script>";

}

$userid=$_SESSION['userid'];
include ('mysqli_connect.php');

//取数据库中user的用户名
$sql="select user_name from user_table where user_id={$userid}";
$res=mysqli_query($dbc,$sql);
$result=mysqli_fetch_array($res);


?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>我的影视库 || 我的信息</title>
    <link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <style>
        body{
            width: 100%;
            overflow: hidden;
            background: url("300046-106.jpg") no-repeat;
            background-size:cover;
            color: antiquewhite;
        }
    </style>
</head>
<body>
<nav class="navbar navbar-default navbar-static-top" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-brand" href="#">我的影视库</a>
        </div>
        <div>
            <ul class="nav navbar-nav">
                <li><a href="user_index.php">主页</a></li>
                <li><a href="user_querymovie.php">影视查询</a></li>-->
                <li><a href="user_sheet.php">我的收藏</a></li>-->
                <li class="active dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">个人信息<b class="caret"></b></a>

                    <ul class="dropdown-menu">
                        <li><a href="user_info.php">用户信息</a></li>
                        <li><a href="user_repass.php">修改密码</a></li>
                    </ul>
                </li>
                <li><a href="index.php">退出</a></li>
            </ul>
        </div>
    </div>
</nav>
<?php



$sqla="select * from user_table where user_id={$userid};";

$resa=mysqli_query($dbc,$sqla);
$resulta=mysqli_fetch_array($resa);

$nowyear=date("Y");//计算当前年份
$user_nowage=$nowyear - $resulta['user_age'];//计算当前用户年龄
?>
<div class="col-xs-5 col-md-offset-3" style="position: relative;top: 25%">
    <div class="panel panel-primary">
        <div class="panel-heading">
            <h3 class="panel-title">我的用户信息</h3>
        </div>
        <div class="panel-body">
            <a href="#" class="list-group-item"><?php echo "<p>用户ID:{$resulta['user_id']}</p><br/>"; ?></a>
            <a href="#" class="list-group-item"><?php  echo "<p>用户名:{$resulta['user_name']}</p><br/>";  ?></a>
            <a href="#" class="list-group-item"><?php    echo "<p>性别:{$resulta['user_sex']}</p><br/>"; ?></a>
            <a href="#" class="list-group-item"><?php echo "<p>年龄:{$user_nowage}</p><br/>";  ?></a>
<!--            <a href="#" class="list-group-item">--><?php //    echo "<p>居住地:{$resulta['address']}</p><br/>";  ?><!--</a>-->
<!--            <a href="#" class="list-group-item">--><?php //   echo "<p>电话:{$resulta['telcode']}</p><br/>"; ?><!--</a>-->
            <?php echo "<a style='color: #AA0000;font-size: larger' href='user_info_edit.php'><strong>修改</strong></a>"; ?>
        </div>
    </div>
</div>


</body>
</html>